fix: disable mouse tracking on Windows terminal exit#153
Open
Ashwinhegde19 wants to merge 1 commit intoKilo-Org:devfrom
Open
fix: disable mouse tracking on Windows terminal exit#153Ashwinhegde19 wants to merge 1 commit intoKilo-Org:devfrom
Ashwinhegde19 wants to merge 1 commit intoKilo-Org:devfrom
Conversation
Add explicit terminal state reset sequences after renderer cleanup to ensure
SGR mouse tracking is properly disabled on exit. On Windows, the terminal may
still report mouse events as raw escape sequences if mouse tracking wasn't
fully disabled. This fix adds:
1. resetTerminalState() function that writes disable sequences for:
- Normal and button-event mouse tracking
- Any-event mouse tracking (all movement)
- SGR extended mouse mode
- RXVT mouse mode
- Kitty keyboard protocol
- Text attributes
2. Calls resetTerminalState() in three exit paths:
- Normal exit via ExitProvider (exit/quit/:q commands)
- Error boundary Ctrl+C handler
- process.on('exit') safety net for all other exits
Fixes Kilo-Org#151
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes GitHub Issue #151: After closing the CLI on Windows, mouse movement inserts raw escape sequences like
[555;27;21Minto the terminal. These are SGR mouse tracking events that should have been disabled on exit.Solution
Added explicit terminal state reset sequences after renderer cleanup to ensure all mouse tracking modes are properly disabled, regardless of the exit path:
New
resetTerminalState()function that writes disable sequences for:\x1b[?1000l)\x1b[?1002l)\x1b[?1003l)\x1b[?1006l)\x1b[?1015l)\x1b[<u)\x1b[0m)Three exit path handlers:
/exit,quit,:qcommands)process.on('exit')safety net for all other exit pathsTest Plan
Test on your Windows machine by:
bun dev/exitcommand, typingexit/quit/:q